Passed
Push — master ( e0ac9d...715f03 )
by Paul
04:37
created

GLSR.Pointers.init_   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 12
rs 9.8
c 0
b 0
f 0
1
/** global: GLSR, jQuery */
2
;(function( $ ) {
3
4
	'use strict';
5
6
	GLSR.Pointers = function() {
7
		$.each( GLSR.pointers, function( i, pointer ) {
8
			this.init_( pointer );
9
		}.bind( this ));
10
	};
11
12
	GLSR.Pointers.prototype = {
13
		/** @return void */
14
		close_: function( pointerId ) { // string
15
			$.post( GLSR.ajaxurl, {
16
				action: 'dismiss-wp-pointer',
17
				pointer: pointerId,
18
			});
19
		},
20
21
		/** @return void */
22
		init_: function( pointer ) { // object
23
			$( pointer.target ).pointer({
24
				content: pointer.options.content,
25
				position: pointer.options.position,
26
				close: this.close_.bind( pointer.id ),
27
			})
28
			.pointer( 'open' )
29
			.pointer( 'sendToTop' );
30
			$( document ).on( 'wp-window-resized', function() {
31
				$( pointer.target ).pointer( 'reposition' );
32
			});
33
		},
34
	};
35
})( jQuery );
36